 #include <iostream>
 #include <cmath>
 #include <algorithm>
 #include <cstring>
 #include <vector>
 #include <map>
 #include <queue>
 #include <cstdio>
 #include <string>
 #include <stack>
 #include <set>
 #define IOS ios::sync_with_stdio(false), cin.tie(0)
 using namespace std;
 typedef long long ll;
 ll pre[1000000];

 int main()
 {
     IOS;
    ll n,x;
    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>x;
        pre[i]=pre[i-1]+x;
    }    
    ll s;
    cin>>s;
    ll st,len;
    while(s--){
        cin>>st>>len;
        cout<<pre[st+len-1]-pre[st-1]<<endl;
    }
     getchar();
     getchar();
     return 0;
 }
 